<%--
  Created by IntelliJ IDEA.
  User: Panda
  Date: 2021/4/27
  Time: 16:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <form method="post">
        uname<input name="uname" id="uname"><span id="message"></span>
        upwd<input name="upwd" id="upwd">
        <button type="button" id="btnReg">reg</button>
    </form>
</body>
</html>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
    $(document).ready(function(){
        $("#uname").blur(function(){
            $.ajax({
                url:"login/"+$("#uname").val(),
                type:"get",
                success:function(response){
                    alert(response);
                    $("#message").html(response);
                }
            });
        });
        $("#btnReg").click(function(){
            $.ajax({
                url:"login",
                type:"post",
                data:{"uname":$("#uname").val(),"upwd":$("#upwd").val()},
                success:function(response){
                    alert(response+":"+(response==="ok"));
                    if(response==="ok"){
                        location.href="login.jsp";
                    }
                }
            });
        });
    });

</script>
